#include <SFML/Graphics.hpp>

#include <SmegCore/Entity/BaseEntity.hpp>
#include <SmegCore/Entity/EntityManager.hpp>

class Character : public smeg::core::BaseEntity 
{
public:
    Character( sf::RenderWindow* _pRW,
        const sf::Vector2f& _center         = sf::Vector2f(),
        float _fAngleDeg                    = 0.0f,
        bool _bIsStatic                     = false ) :
        smeg::core::BaseEntity( _pRW, "data/ground_text.png", _center, _fAngleDeg, _bIsStatic )
    {
    }

    void Update() {
        if ( sf::Keyboard::isKeyPressed( sf::Keyboard::Up ) ) {
            MoveY( -10.0f );
        } else if ( sf::Keyboard::isKeyPressed( sf::Keyboard::Down ) ) {
            MoveY( 10.0f );
        }
        if ( sf::Keyboard::isKeyPressed( sf::Keyboard::Left ) ) {
            MoveX( -10.0f );
        } else if ( sf::Keyboard::isKeyPressed( sf::Keyboard::Right ) ) {
            MoveX( 10.0f );
        }
    }
};

int main( int argc, char** argv ) {
    sf::RenderWindow window( sf::VideoMode( 1024, 768 ), "SmegShadow" );
    Character* chr = new Character( &window );

    while ( window.isOpen() ) {
        sf::Event event;
        while ( window.pollEvent( event ) ) {
            if ( sf::Event::Closed == event.type ) {
                window.close();
            }

            window.clear( sf::Color::Black );

            chr->Update();
            chr->Draw();

            window.display();
        }
    }

    smeg::core::EntityManager::GetInstance()->ClearScene();

    return EXIT_SUCCESS;
}